﻿using DBUtil;
using System;
using NUnit.Framework;
using System.Linq;

namespace Test.Sqlite
{
    [TestFixture]
    public class TestBase
    {
        protected DBAccess db = null;

        protected void DropTableIfExist(string tableName)
        {
            db.ExecuteSql(db.Manage.DropTableIfExistSql(tableName));
        }
        protected void DropTable(string tableName)
        {
            db.ExecuteSql(db.Manage.DropTableSql(tableName));
        }
        protected void TruncateTable(string tableName)
        {
            db.ExecuteSql($"truncate table {tableName}");
        }

        public TestBase()
        {
            DBUtil.DBFactory.AddDBSupport<DBUtil.Provider.Sqlite.SqliteDBFactory>();
            var absPath = System.IO.Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "empty.db").First();
            db = DBFactory.CreateDB("SQLITE", $"Data Source={absPath};");
        }
    }
}
